package com.ysu.zyw.fk.handler;

import com.ysu.zyw.common.exception.SystemException;
import freemarker.core.Environment;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Writer;

/**
 * Created by ZeRur on 2016/1/17.
 * @author yaowu.zhang
 */
public class FreemarkerExceptionHandler implements TemplateExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(FreemarkerExceptionHandler.class);

    public void handleTemplateException(TemplateException te, Environment env, Writer out) throws TemplateException {
        logger.error("freemarker render raised an exception. " + te.getMessage(), te);
        throw new SystemException("freemarker render raised an exception", te);
    }

}
